//
//  UIBarItem+extension.swift
//  微博
//
//  Created by hejinyin on 2017/9/1.
//  Copyright © 2017年 WangQiang. All rights reserved.
//

import UIKit
extension UIBarButtonItem{
    //
    convenience  init(title:String ,image:String? = nil ,fontSize: CGFloat = 16 , target:AnyObject? , action: Selector ) {
        let btn = UIButton.init(title, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange, fontSize: fontSize)
        if let imageName = image {
          btn.setImage(UIImage.init(named: imageName), for: .normal)
          btn.setImage(UIImage.init(named: imageName + "_highlighted"), for: .highlighted)
        }
        
        btn.sizeToFit()
        btn.addTarget(target, action: action, for: .touchUpInside)
        
        self.init(customView: btn)
    }
    convenience  init(backTitle:String , target:AnyObject? ,action:Selector){
        self.init(title: backTitle, image:"navigationbar_back_withtext",target: target, action: action)
    }
}
